package jihe;

import java.security.KeyStore.Entry;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeMap;

public class shiyanc {
	  public static void main(String[] args) {
		  int i=0;
		  Scanner sc=new Scanner(System.in);
		 Map<String,Integer> map=new  HashMap<String,Integer>();
		  while(sc.hasNext()){
			String str=sc.next();
			Integer xy=map.get(str);
			if(str.equals("!!!!!")) break;
			else if(xy==null) map.put(str, 1);
			else map.put(str, xy+1);
			}
		List<Map.Entry<String,Integer>> list=new ArrayList<Map.Entry<String,Integer>>();
		for(Map.Entry<String, Integer> e:map.entrySet()){
			list.add(e);
		}
		System.out.println(list.size());
		List<Map.Entry<String,Integer>> list1=new ArrayList<Map.Entry<String,Integer>>(map.entrySet());
		
		 Collections.sort(list,new Comparator<Map.Entry<String,Integer>>(){
			 

			@Override
			public int compare(java.util.Map.Entry<String, Integer> o1, java.util.Map.Entry<String, Integer> o2) {
				// TODO Auto-generated method stub
				if(o2.getValue()-o1.getValue()==0)
					 return o1.getKey().compareTo(o2.getKey());
			    else return o2.getValue()-o1.getValue();
			}
		 });
		 for (Map.Entry<String, Integer> entry :list) 
		 {
        if(i>9) break;
        else{   
        	System.out.println(entry.getKey()+"="+entry.getValue());
        }
		    i++;
		 }
	  }
}	  
		  
		  
		  
	  






